import { DictTag } from "@/components/common/DictTag";
import { goodsNameRend, goodsCodeRend } from "@/utils/tableColumns";

export function useColumns() {
  // 代配货商品列表
  const dphGoodsColumns: TableColumnList = [
    {
      label: "勾选列", // 如果需要表格多选，此处label必须设置
      type: "selection",
      fixed: "left"
    },
    {
      label: "商品名称/规格名称",
      prop: "goodsName",
      minWidth: 200,
      align: "left",
      fixed: "left",
      cellRenderer: goodsNameRend
    },
    {
      label: "商品编码/规格编码",
      prop: "goodsCode",
      align: "left",
      minWidth: 150,
      cellRenderer: goodsCodeRend
    },
    {
      label: "商品条码",
      prop: "barCode",
      minWidth: 120,
      formatter: row => row.barCode || "--"
    },
    {
      label: "商品类型",
      prop: "goodsType",
      minWidth: 100,
      cellRenderer: ({ row }) => (
        <DictTag dict-type="PRODUCT_TYPE" dict-value={row.goodsType} />
      )
    },
    {
      label: "数量",
      prop: "goodsAmount",
      width: 80
    },
    {
      label: "已发货数量",
      prop: "quantityShipped",
      width: 100
    },
    {
      label: "配货数量",
      prop: "distributionCount",
      minWidth: 150,
      cellRenderer: ({ row }) => (
        <el-input-number
          v-model={row.distributionCount}
          class="!w-[130px]"
          placeholder="请输入"
          precision={0}
          min={1}
          max={row.goodsAmount}
        />
      )
    },
    {
      label: "已入库数量",
      prop: "storeAmount",
      width: 100
    },
    {
      label: "待入库数量",
      prop: "stayStoreAmount",
      width: 100
    }
  ];

  // 已配货商品列表
  const yphGoodsColumns: TableColumnList = [
    {
      label: "配货出库单",
      prop: "distributionCode",
      align: "left",
      minWidth: 165
    },
    {
      label: "商品名称/规格名称",
      prop: "goodsName",
      minWidth: 200,
      align: "left",
      cellRenderer: goodsNameRend
    },
    {
      label: "商品编码/规格编码",
      prop: "goodsCode",
      align: "left",
      minWidth: 150,
      cellRenderer: goodsCodeRend
    },
    {
      label: "商品条码",
      prop: "barCode",
      minWidth: 120
    },
    {
      label: "商品类型",
      prop: "goodsType",
      minWidth: 100,
      cellRenderer: ({ row }) => (
        <DictTag dict-type="PRODUCT_TYPE" dict-value={row.goodsType} />
      )
    },
    {
      label: "数量",
      prop: "quantityNum",
      minWidth: 80
    }
  ];

  const fhGoodsColumns: TableColumnList = [
    {
      label: "勾选列", // 如果需要表格多选，此处label必须设置
      type: "selection",
      selectable: row => !row.disabled,
      fixed: "left"
    },
    {
      label: "商品名称/规格名称",
      prop: "goodsName",
      minWidth: 200,
      align: "left",
      fixed: "left",
      cellRenderer: goodsNameRend
    },
    {
      label: "商品编码/规格编码",
      prop: "goodsCode",
      align: "left",
      minWidth: 150,
      cellRenderer: goodsCodeRend
    },
    {
      label: "商品条码",
      prop: "barCode",
      minWidth: 120,
      formatter: row => row.barCode || "--"
    },
    {
      label: "商品类型",
      prop: "goodsType",
      minWidth: 85,
      cellRenderer: ({ row }) => (
        <DictTag dict-type="PRODUCT_TYPE" dict-value={row.goodsType} />
      )
    },
    {
      label: "数量",
      prop: "goodsAmount",
      minWidth: 80
    },
    {
      label: "待发货数量",
      prop: "waitingShipped",
      minWidth: 100
    },
    {
      label: "已发货数量",
      prop: "quantityShipped",
      minWidth: 100
    },
    {
      label: "发货数量",
      prop: "sendCounts",
      minWidth: 150,
      slot: "sendCounts"
      // cellRenderer: ({ row }) => (
      //   <el-input-number
      //     v-model={row.sendCounts}
      //     class="!w-[130px]"
      //     placeholder="请输入"
      //     precision={0}
      //     min={1}
      //     max={row.goodsAmount}
      //   />
      // )
    }
  ];

  return {
    dphGoodsColumns,
    yphGoodsColumns,
    fhGoodsColumns
  };
}
